package com.lm.temporal.workflow;

import com.lm.temporal.activities.OrderActivities;
import io.temporal.activity.ActivityOptions;
import io.temporal.workflow.Workflow;

import java.time.Duration;

public class OrderWorkflowImpl implements OrderWorkflow {

    private final OrderActivities activities =
            Workflow.newActivityStub(OrderActivities.class,
                    ActivityOptions.newBuilder()
                            .setStartToCloseTimeout(Duration.ofSeconds(30))
                            .build());

    @Override
    public void processOrder(String orderId) {
        activities.validate(orderId);
        activities.reduceStock(orderId);
        activities.pay(orderId);
        activities.dispatch(orderId);
    }
}